package com.kinyx.framework.db.sentence.res;

import java.util.List;

import javax.util.XArrayList;

import org.junit.Assert;

import com.kinyx.framework.db.configs.DBConfigs;
import com.kinyx.framework.db.configs.DBConfigsHelper;
import com.kinyx.test.entities.impl.DemoEntityR;

import lombok.AllArgsConstructor;

class SUPER {

	protected List<Boolean> list_flag = new XArrayList<Boolean>().xAdd(true).xAdd(false);
	protected List<Integer> list_tableIdx = new XArrayList<Integer>().xAdd(0).xAdd(1).xAdd(2);
	protected List<String> list_param = new XArrayList<String>().xAdd(null).xAdd("foo").xAdd("bar");
	protected List<$Column> list_column = new XArrayList<$Column>()//
			.xAdd(new $Column(DemoEntityR.id, "id", "ID"))//
			.xAdd(new $Column(DemoEntityR.usingStatus, "usingStatus", "USING_STATUS"));

	@AllArgsConstructor
	protected class $Column {
		Column column;
		String fieldName;
		String columnName;
	}

	protected void test_getSentence(final _Sentence sentence, final String expected1, final String expected2, final String expected3, final String expected4) {
		final DBConfigs configs = DBConfigsHelper.getDBConfigs(null);
		Assert.assertEquals(expected1, sentence.getSentence(configs, true, false));
		Assert.assertEquals(expected2, sentence.getSentence(configs, false, false));
		Assert.assertEquals(expected3, sentence.getSentence(configs, true, true));
		Assert.assertEquals(expected4, sentence.getSentence(configs, false, true));
	}

	protected void test_toString(final _Sentence sentence, final String expected1, final String expected2, final String expected3, final String expected4) {
		sentence.isSQL = true;
		sentence.withTableAlias = false;
		Assert.assertEquals(expected1, sentence.toString());

		sentence.isSQL = false;
		sentence.withTableAlias = false;
		Assert.assertEquals(expected2, sentence.toString());

		sentence.isSQL = true;
		sentence.withTableAlias = true;
		Assert.assertEquals(expected3, sentence.toString());

		sentence.isSQL = false;
		sentence.withTableAlias = true;
		Assert.assertEquals(expected4, sentence.toString());
	}

}
